﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Shared.Method;
using Shared.Model;
using Newtonsoft.Json;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Data;

namespace Client
{
    public class MethodWcf
    {
        //private static List<ServiceTRClient> s_listClient = new List<ServiceTRClient>();
        //private static readonly object LOCKOBJ = new object();

        //private static ServiceTRClient GetWcfClient()
        //{
        //    ServiceTRClient client = null;
        //    if (s_listClient.Count == 0)
        //    {
        //        client = new ServiceTRClient();
        //        s_listClient.Add(client);
        //        return client;
        //    }

        //    lock (LOCKOBJ)
        //    {
        //        client = (from c in s_listClient
        //                  where c.IsUsed == false
        //                  select c).FirstOrDefault();

        //        if (client == null)
        //        {
        //            client = new ServiceTRClient();
        //            s_listClient.Add(client);
        //        }

        //        client.IsUsed = true;

        //        return client;
        //    }
        //}
        /// <summary>
        /// 接口授权码
        /// </summary>
        public static string KEY { get; set; }

        private static void AddMsgHeader(string keyStr)
        {
            //return;
            MessageHeader header = MessageHeader.CreateHeader("header", "CheckCode", Encrypt.GetCheckCode(KEY,keyStr));
            OperationContext.Current.OutgoingMessageHeaders.Add(header);
        }

        /// <summary>
        /// 写顶层测试数据
        /// </summary>
        /// <param name="top"></param>
        /// <returns></returns>
        public static ResultSet InsertTestTopClient(TEST_TOP top)
        {
            top.SetNothing();
            string value = JsonConvert.SerializeObject(top);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertTestTop(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询测试最终结果
        /// </summary>
        /// <param name="top"></param>
        /// <returns></returns>
        public static ResultSet<List<TEST_TOP>> SelectTestTopClient(TEST_TOP top)
        {
            top.SetNothing();
            string value = JsonConvert.SerializeObject(top);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectTestTop(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<TEST_TOP>>>(reponse);
            }
        }

        ///// <summary>
        ///// 插入二层测试数据
        ///// </summary>
        ///// <param name="second"></param>
        ///// <returns></returns>
        //public static ResultSet InsertTestSecondClient(TEST_SECOND second)
        //{
        //    second.SetNothing();
        //    string value = JsonConvert.SerializeObject(second);
        //    ServiceTRClient client = new ServiceTRClient();
        //    string reponse = client.InsertTestSecond(value);
        //    client.Close();
        //    return JsonConvert.DeserializeObject<ResultSet>(reponse);
        //}
        ///// <summary>
        ///// 查询第二次测试数据
        ///// </summary>
        ///// <param name="second"></param>
        ///// <returns></returns>
        //public static ResultSet<List<TEST_SECOND>> SelectTestSecondClient(TEST_SECOND second)
        //{
        //    second.SetNothing();
        //    string value = JsonConvert.SerializeObject(second);
        //    ServiceTRClient client = new ServiceTRClient();
        //    string reponse = client.SelectTestSecond(value);
        //    client.Close();
        //    return JsonConvert.DeserializeObject<ResultSet<List<TEST_SECOND>>>(reponse);
        //}

        /// <summary>
        /// 插入第三层测试数据
        /// </summary>
        /// <param name="third"></param>
        /// <returns></returns>
        //public static ResultSet InsertTestThirdClient(TEST_THIRD third)
        //{
        //    third.SetNothing();
        //    string value = JsonConvert.SerializeObject(third);
        //    ServiceTRClient client = new ServiceTRClient();
        //    string reponse = client.InsertTestThird(value);
        //    client.Close();
        //    return JsonConvert.DeserializeObject<ResultSet>(reponse);
        //}
        /// <summary>
        /// 工序开始请求
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public static ResultSet CanStartClient(StartRequest req)
        {
            string value = JsonConvert.SerializeObject(req);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.CanStart(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 插入工位信息
        /// </summary>
        /// <param name="statioin"></param>
        /// <returns></returns>
        public static ResultSet InsertStationClient(STATION statioin)
        {
            statioin.SetNothing();
            string value = JsonConvert.SerializeObject(statioin);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertStation(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询某个条件下的工位条目数量
        /// </summary>
        /// <param name="statioin"></param>
        /// <returns></returns>
        public static ResultSet SelectStationCountClient(STATION statioin)
        {
            statioin.SetNothing();
            string value = JsonConvert.SerializeObject(statioin);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectStationCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 获取工序信息
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static ResultSet<List<STATION>> SelectStationClient(STATION station)
        {
            station.SetNothing();
            string value = JsonConvert.SerializeObject(station);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectStation(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<STATION>>>(reponse);
            }
        }
        /// <summary>
        /// 修改工位信息
        /// </summary>
        /// <param name="statioin"></param>
        /// <returns></returns>
        public static ResultSet UpdateStationClient(STATION statioin)
        {
            statioin.SetNothing();
            string value = JsonConvert.SerializeObject(statioin);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateStation(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询产线信息
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static ResultSet<List<LINE>> SelectLineClient(LINE line)
        {
            line.SetNothing();
            string value = JsonConvert.SerializeObject(line);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectLine(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<LINE>>>(reponse);
            }
        }
        /// <summary>
        /// 查询工序信息
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static ResultSet<List<NODE>> SelectNodeClient(NODE node)
        {
            node.SetNothing();
            string value = JsonConvert.SerializeObject(node);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectNode(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<NODE>>>(reponse);
            }
        }
        /// <summary>
        /// 插入工序信息
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static ResultSet InsertNodeClient(NODE node)
        {
            node.SetNothing();
            string value = JsonConvert.SerializeObject(node);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertNode(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询某条件下工序的数量
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static ResultSet SelectNodeCountClient(NODE node)
        {
            node.SetNothing();
            string value = JsonConvert.SerializeObject(node);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectNodeCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 更新工序信息
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static ResultSet UpdateNodeClient(NODE node)
        {
            node.SetNothing();
            string value = JsonConvert.SerializeObject(node);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateNode(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 删除工序信息
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static ResultSet DeleteNodeClient(NODE node)
        {
            node.SetNothing();
            string value = JsonConvert.SerializeObject(node);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.DeleteNode(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        /// <summary>
        /// 查询员工信息
        /// </summary>
        /// <param name="worker"></param>
        /// <returns></returns>
        public static ResultSet<List<WORKER>> SelectWorkerClient(WORKER worker)
        {
            worker.SetNothing();
            string value = JsonConvert.SerializeObject(worker);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectWorker(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<WORKER>>>(reponse);
            }
        }

        /// <summary>
        /// 更新产品状态信息
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static ResultSet UpdateProductClient(PRODUCT product)
        {
            product.SetNothing();
            string value = JsonConvert.SerializeObject(product);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateProduct(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        /// <summary>
        /// 插入一条产品信息
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static ResultSet InsertProductClient(PRODUCT product)
        {
            product.SetNothing();
            string value = JsonConvert.SerializeObject(product);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertProduct(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 获得产品的数量
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static ResultSet SelectProductCountClient(PRODUCT pro)
        {
            pro.SetNothing();
            string value = JsonConvert.SerializeObject(pro);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProductCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询产品信息
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static ResultSet<List<PRODUCT>> SelectProductClient(PRODUCT pro)
        {
            pro.SetNothing();
            string value = JsonConvert.SerializeObject(pro);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProduct(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<PRODUCT>>>(reponse);
            }
        }
        /// <summary>
        /// 插入过程信息
        /// </summary>
        /// <param name="process"></param>
        /// <returns></returns>
        public static ResultSet InsertProcessClient(PROCESS process)
        {
            process.SetNothing();
            string value = JsonConvert.SerializeObject(process);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertProcess(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        /// <summary>
        /// 查询过程数据表
        /// </summary>
        /// <param name="process"></param>
        /// <returns></returns>
        public static ResultSet<List<PROCESS>> SelectProcessClient(PROCESS process)
        {
            process.SetNothing();
            string value = JsonConvert.SerializeObject(process);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProcess(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<PROCESS>>>(reponse);
            }
        }
        /// <summary>
        /// 查询过程数量
        /// </summary>
        /// <param name="proc"></param>
        /// <returns></returns>
        public static ResultSet SelectProcessCountClient(PROCESS proc)
        {
            proc.SetNothing();
            string value = JsonConvert.SerializeObject(proc);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProcessCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        /// <summary>
        /// 查询装盒的情况
        /// </summary>
        /// <param name="box"></param>
        /// <returns></returns>
        public static ResultSet<List<BOX_MODEM>> SelectBoxModemClient(BOX_MODEM box)
        {
            box.SetNothing();
            string value = JsonConvert.SerializeObject(box);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectBoxModem(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<BOX_MODEM>>>(reponse);
            }
        }
        /// <summary>
        /// 查询某条件下盒子的数量
        /// </summary>
        /// <param name="box"></param>
        /// <returns></returns>
        public static ResultSet SelectBoxModemCountClient(BOX_MODEM box)
        {
            box.SetNothing();
            string value = JsonConvert.SerializeObject(box);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectBoxModemCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 插入包装盒数据
        /// </summary>
        /// <param name="box"></param>
        /// <returns></returns>
        public static ResultSet InsertBoxModemClient(BOX_MODEM box)
        {
            box.SetNothing();
            string value = JsonConvert.SerializeObject(box);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertBoxModem(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 更新包装表信息
        /// </summary>
        /// <param name="box"></param>
        /// <returns></returns>
        public static ResultSet UpdateBoxModemClient(BOX_MODEM box)
        {
            box.SetNothing();
            string value = JsonConvert.SerializeObject(box);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateBoxModem(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查找modem表中的数据
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public static ResultSet<List<Device_Data>> SelectDeviceDataClient(Device_Data device)
        {
            device.SetNothing();
            string value = JsonConvert.SerializeObject(device);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectDeviceData(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<Device_Data>>>(reponse);
            }
        }
        /// <summary>
        /// 查询某条件下产品信息的数量
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public static ResultSet SelectDeviceDataCountClient(Device_Data device)
        {
            device.SetNothing();
            string value = JsonConvert.SerializeObject(device);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectDeviceDataCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 更新产品SN信息
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public static ResultSet UpdateDeviceDataClient(Device_Data device)
        {
            device.SetNothing();
            string value = JsonConvert.SerializeObject(device);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateDeviceData(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 导入Device信息
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public static ResultSet InsertDeviceDataClient(Device_Data device)
        {
            device.SetNothing();
            string value = JsonConvert.SerializeObject(device);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertDeviceData(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询所有的流程集合
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static ResultSet<List<FLOW_GROUP>> SelectFlowGroupClient(FLOW_GROUP group)
        {
            group.SetNothing();
            string value = JsonConvert.SerializeObject(group);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectFlowGroup(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<FLOW_GROUP>>>(reponse);
            }
        }
        /// <summary>
        /// 获得插入流程集合数据
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static ResultSet InsertFlowGroupClient(FLOW_GROUP group)
        {
            group.SetNothing();
            string value = JsonConvert.SerializeObject(group);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertFlowGroup(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 更新流程集合名称
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static ResultSet UpdateFlowGroupClient(FLOW_GROUP group)
        {
            group.SetNothing();
            string value = JsonConvert.SerializeObject(group);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateFlowGroup(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询流程集合的数量
        /// </summary>
        /// <param name="group"></param>
        /// <returns></returns>
        public static ResultSet SelectFlowGroupCountClient(FLOW_GROUP group)
        {
            group.SetNothing();
            string value = JsonConvert.SerializeObject(group);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectFlowGroupCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        /// <summary>
        /// 查询所有的流程
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public static ResultSet<List<FLOW>> SelectFlowClient(FLOW flow)
        {
            flow.SetNothing();
            string value = JsonConvert.SerializeObject(flow);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectFlow(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<FLOW>>>(reponse);
            }
        }
        /// <summary>
        /// 获得插入流程集合数据
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public static ResultSet InsertFlowClient(FLOW flow)
        {
            flow.SetNothing();
            string value = JsonConvert.SerializeObject(flow);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertFlow(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 更新流程
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public static ResultSet UpdateFlowClient(FLOW flow)
        {
            flow.SetNothing();
            string value = JsonConvert.SerializeObject(flow);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateFlow(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询流程的数量
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public static ResultSet SelectFlowCountClient(FLOW flow)
        {
            flow.SetNothing();
            string value = JsonConvert.SerializeObject(flow);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectFlowCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 更新产线信息
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static ResultSet UpdateLineClient(LINE line)
        {
            line.SetNothing();
            string value = JsonConvert.SerializeObject(line);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateLine(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 插入数据到产线
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static ResultSet InsertLineClient(LINE line)
        {
            line.SetNothing();
            string value = JsonConvert.SerializeObject(line);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertLine(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询产线的条数
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static ResultSet SelectCountLineClient(LINE line)
        {
            line.SetNothing();
            string value = JsonConvert.SerializeObject(line);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectCountLine(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询员工数量
        /// </summary>
        /// <param name="worker"></param>
        /// <returns></returns>
        public static ResultSet SelectCountWorkerClient(WORKER worker)
        {
            worker.SetNothing();
            string value = JsonConvert.SerializeObject(worker);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectCountWorker(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 写入员工信息
        /// </summary>
        /// <param name="worker"></param>
        /// <returns></returns>
        public static ResultSet InsertWorkerClient(WORKER worker)
        {
            worker.SetNothing();
            string value = JsonConvert.SerializeObject(worker);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertWorker(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 更新员工信息
        /// </summary>
        /// <param name="worker"></param>
        /// <returns></returns>
        public static ResultSet UpdateWorkerClient(WORKER worker)
        {
            worker.SetNothing();
            string value = JsonConvert.SerializeObject(worker);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateWorker(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询软件版本和更新地址信息
        /// </summary>
        /// <param name="soft"></param>
        /// <returns></returns>
        public static ResultSet<List<SOFTWARE>> SelectSoftwareClient(SOFTWARE soft)
        {
            soft.SetNothing();
            string value = JsonConvert.SerializeObject(soft);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectSoftware(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<SOFTWARE>>>(reponse);
            }
        }
        ///// <summary>
        ///// 获取产品最小的SN号码
        ///// </summary>
        ///// <param name="lineId">产线ID</param>
        ///// <returns></returns>
        //public static ResultSet GetMinProductSNClient(CONDITION_SN conditionSn)
        //{
        //    conditionSn.SetNothing();
        //    string value = JsonConvert.SerializeObject(conditionSn);
        //    ServiceTRClient client = new ServiceTRClient();
        //    string reponse = client.GetMinProductSN(value);
        //    client.Close();
        //    return JsonConvert.DeserializeObject<ResultSet>(reponse);
        //}
        ///// <summary>
        ///// 获取最小的的产品包装SN号码,SN号写MESSAGE中
        ///// </summary>
        ///// <param name="lineId"></param>
        ///// <returns></returns>
        //public static ResultSet GetMinBoxSnClient(CONDITION_SN conditionSn)
        //{
        //    conditionSn.SetNothing();
        //    string value = JsonConvert.SerializeObject(conditionSn);

        //    ServiceTRClient client = new ServiceTRClient();
        //    string reponse = client.GetMinBoxSn(value);

        //    client.Close();
        //    return JsonConvert.DeserializeObject<ResultSet>(reponse);
        //}
        ///// <summary>
        ///// 获取最小的可以包装的产品SN号码
        ///// </summary>
        ///// <param name="lineId"></param>
        ///// <returns></returns>
        //public static ResultSet GetPackingProductSnClient(CONDITION_SN conditionSn)
        //{
        //    conditionSn.SetNothing();
        //    string value = JsonConvert.SerializeObject(conditionSn);

        //    ServiceTRClient client = new ServiceTRClient();
        //    string reponse = client.GetPackingProductSn(value);

        //    client.Close();
        //    return JsonConvert.DeserializeObject<ResultSet>(reponse);
        //}
        ///// <summary>
        ///// 分配盒号，箱号
        ///// </summary>
        ///// <param name="conditionSn"></param>
        ///// <returns></returns>
        //public static ResultSet DistrubiteSnClient(CONDITION_SN conditionSn)
        //{
        //    conditionSn.SetNothing();
        //    string value = JsonConvert.SerializeObject(conditionSn);
        //    ServiceTRClient client = new ServiceTRClient();
        //    string response = client.DistrubiteSn(value);
        //    client.Close();
        //    return JsonConvert.DeserializeObject<ResultSet>(response);
        //}

        /// <summary>
        /// 写DeviceType的信息
        /// </summary>
        /// <param name="deviceType"></param>
        /// <returns></returns>
        public static ResultSet InsertDeviceTypeClient(Device_Type deviceType)
        {
            deviceType.SetNothing();
            string value = JsonConvert.SerializeObject(deviceType);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertDeviceType(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 更新deviceType的信息
        /// </summary>
        /// <param name="deviceType"></param>
        /// <returns></returns>
        public static ResultSet UpdateDeviceTypeClient(Device_Type deviceType)
        {
            deviceType.SetNothing();
            string value = JsonConvert.SerializeObject(deviceType);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateDeviceType(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 查询产品配置信息
        /// </summary>
        /// <param name="deviceType"></param>
        /// <returns></returns>
        public static ResultSet<List<Device_Type>> SelectDeviceTypeClient(Device_Type deviceType)
        {
            deviceType.SetNothing();
            string value = JsonConvert.SerializeObject(deviceType);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectDeviceType(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<Device_Type>>>(reponse);
            }
        }

        /// <summary>
        /// 查询是否存在BOSA_DATA数据
        /// </summary>
        /// <param name="bosa"></param>
        /// <returns></returns>
        public static ResultSet<List<BOSA_DATA>> SelectBosaDataClient(BOSA_DATA bosa)
        {
            bosa.SetNothing();
            string value = JsonConvert.SerializeObject(bosa);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectBosaData(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<BOSA_DATA>>>(reponse);
            }
        }
        /// <summary>
        /// 更新BOSA数据
        /// </summary>
        /// <param name="bosa"></param>
        /// <returns></returns>
        public static ResultSet UpdateBosaDataClient(BOSA_DATA bosa)
        {
            bosa.SetNothing();
            string value = JsonConvert.SerializeObject(bosa);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateBosaData(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        /// <summary>
        /// 查询BOSA数据数量
        /// </summary>
        /// <param name="bosa"></param>
        /// <returns></returns>
        public static ResultSet SelectBosaDataCountClient(BOSA_DATA bosa)
        {
            bosa.SetNothing();
            string value = JsonConvert.SerializeObject(bosa);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectBosaDataCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 写入BOSA数据
        /// </summary>
        /// <param name="bosa"></param>
        /// <returns></returns>
        public static ResultSet InsertBosaDataClient(BOSA_DATA bosa)
        {
            bosa.SetNothing();
            string value = JsonConvert.SerializeObject(bosa);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertBosaData(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }
        /// <summary>
        /// 获取省份信息表
        /// </summary>
        /// <param name="province"></param>
        /// <returns></returns>
        public static ResultSet<List<PROVINCE>> SelectProvinceClient(PROVINCE province)
        {
            province.SetNothing();
            string value = JsonConvert.SerializeObject(province);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProvince(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<PROVINCE>>>(reponse);
            }
        }
        /// <summary>
        /// 获取SN号码分配情况
        /// </summary>
        /// <param name="sn"></param>
        /// <returns></returns>
        //public static ResultSet<List<View_SnList>> SelectViewSn(View_SnList sn)
        //{
        //    sn.SetNothing();
        //    string value = JsonConvert.SerializeObject(sn);
        //    ServiceTRClient client = new ServiceTRClient();
        //    string reponse = client.SelectViewSnList(value);
        //    client.Close();
        //    return JsonConvert.DeserializeObject<ResultSet<List<View_SnList>>>(reponse);
        //}
        /// <summary>
        /// 查询产能统计表
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public static ResultSet<List<PRODUCT_COUNT_DATA>> SelectProductCountDataClient(PRODUCT_COUNT_DATA count)
        {
            count.SetNothing();
            string value = JsonConvert.SerializeObject(count);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProductCountData(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<PRODUCT_COUNT_DATA>>>(reponse);
            }
        }
        /// <summary>
        /// 查询某条件下产能数据
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public static ResultSet SelectProductCountDataCountClient(PRODUCT_COUNT_DATA count)
        {
            count.SetNothing();
            string value = JsonConvert.SerializeObject(count);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProductCountDataCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet<List<YCD_DEVICE>> SelectYcdDeviceClient(YCD_DEVICE ycdDevice)
        {
            ycdDevice.SetNothing();
            string value = JsonConvert.SerializeObject(ycdDevice);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectYcdDevice(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<YCD_DEVICE>>>(reponse);
            }
        }

        public static ResultSet SelectYcdDeviceCountClient(YCD_DEVICE ycdDevice)
        {
            ycdDevice.SetNothing();
            string value = JsonConvert.SerializeObject(ycdDevice);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectYcdDeviceCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet InsertYcdDeviceClient(YCD_DEVICE ycdDevice)
        {
            ycdDevice.SetNothing();
            string value = JsonConvert.SerializeObject(ycdDevice);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertYcdDevice(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet UpdateYcdDeviceClient(YCD_DEVICE ycdDevice)
        {
            ycdDevice.SetNothing();
            string value = JsonConvert.SerializeObject(ycdDevice);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateYcdDevice(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet<List<YCD_ORDER>> SelectOrderClient(YCD_ORDER order)
        {

            order.SetNothing();
            string value = JsonConvert.SerializeObject(order);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectOrder(value);

                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<YCD_ORDER>>>(reponse);
            }
        }

        public static ResultSet SelectOrderCountClient(YCD_ORDER order)
        {
            order.SetNothing();
            string value = JsonConvert.SerializeObject(order);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectOrderCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet UpdateOrderClient(YCD_ORDER order)
        {
            order.SetNothing();
            string value = JsonConvert.SerializeObject(order);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateOrder(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet InsertOrderClient(YCD_ORDER order)
        {
            order.SetNothing();
            string value = JsonConvert.SerializeObject(order);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertOrder(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet<List<PRODUCT_SN>> SelectProductSnClient(PRODUCT_SN proSn)
        {
            proSn.SetNothing();
            string value = JsonConvert.SerializeObject(proSn);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProductSn(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<PRODUCT_SN>>>(reponse);
            }
        }

        public static ResultSet SelectProductSnCountClient(PRODUCT_SN proSn)
        {
            proSn.SetNothing();
            string value = JsonConvert.SerializeObject(proSn);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProductSnCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet UpdateProductSnClient(PRODUCT_SN proSn)
        {
            proSn.SetNothing();
            string value = JsonConvert.SerializeObject(proSn);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdateProductSn(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet<List<PRODUCT_SN_LOG>> SelectProductSnLogClient(PRODUCT_SN_LOG snLog)
        {
            snLog.SetNothing();
            string value = JsonConvert.SerializeObject(snLog);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProductSnLog(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<PRODUCT_SN_LOG>>>(reponse);
            }
        }

        public static ResultSet SelectProductSnLogCountClient(PRODUCT_SN_LOG snLog)
        {
            snLog.SetNothing();
            string value = JsonConvert.SerializeObject(snLog);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectProductSnLogCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet<List<PACKING>> SelectPackingClient(PACKING pack)
        {
            pack.SetNothing();
            string value = JsonConvert.SerializeObject(pack);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectPacking(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet<List<PACKING>>>(reponse);
            }
        }

        public static ResultSet SelectPackingCountClient(PACKING pack)
        {
            pack.SetNothing();
            string value = JsonConvert.SerializeObject(pack);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.SelectPackingCount(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet UpdateClient(PACKING pack)
        {
            pack.SetNothing();
            string value = JsonConvert.SerializeObject(pack);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.UpdatePacking(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static ResultSet InsertPackingClient(PACKING pack)
        {
            pack.SetNothing();
            string value = JsonConvert.SerializeObject(pack);
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(value);
                string reponse = client.InsertPacking(value);
                client.Close();
                return JsonConvert.DeserializeObject<ResultSet>(reponse);
            }
        }

        public static string GetYcdMacClient(string ponType)
        {
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(ponType);
                return client.GetYcdMac(ponType);
            }
        }

        public static int ExecuteSQLClient(string sql)
        {
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(sql);
                return client.ExecuteSQL(sql);
            }
        }

        public static string ExecuteReturnSQLClient(string sql)
        {
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(sql);
                return client.ExecuteReturnSQL(sql);
            }
        }
        /// <summary>
        /// Execute any select sql
        /// </summary>
        /// <typeparam name="T">like DataTable/List<Object>/Others</typeparam>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static T SelectJsonClient<T>(string sql) where T : new()
        {
            ServiceTRClient client = new ServiceTRClient();
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
            {
                AddMsgHeader(sql);
                return JsonConvert.DeserializeObject<T>(client.SelectJson(sql));
            }
        }

        public static List<T> Select<T>(T table) where T : TableBase
        {
            string sql = ObjectToSQL.ObjectToSelectSql(table);

            return SelectJsonClient<List<T>>(sql);
        }

        public static int Insert<T>(T table) where T : TableBase
        {
            string sql = ObjectToSQL.ObjectToInsertSql(table);

            return ExecuteSQLClient(sql);
        }

        public static int Update<T>(T table) where T : TableBase
        {
            string sql = ObjectToSQL.ObjectToUpdateSql(table);

            return ExecuteSQLClient(sql);
        }

        public static int Delete<T>(T table) where T : TableBase
        {
            string sql = ObjectToSQL.ObjectToDeleteSql(table);

            return ExecuteSQLClient(sql);
        }
    }
}
